import os
import sys

# 请在此输入您的代码
n,m=map(int,input().split())
a=['0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F','G','H','I','G','K','L','M','N']
ans=""
x=n
while x:

  if x%m<0:
    # 负数 转整数
    ans+=a[x%m-m]
    x//=m
    x+=1
  else:
    ans+=a[x%m]
    x//=m

print("{}={}(base{})".format(n,ans[::-1],m))
